package com.accp.crm.service;

import java.util.List;

import org.hibernate.SessionFactory;


import com.accp.crm.dao.CommonDAO;
import com.accp.crm.entity.PageBean;
import com.accp.crm.entity.Report;



public  class ReportBizService  implements IReportBizService{
	
	
	private CommonDAO<Report> ReportDAO;


    /* (non-Javadoc)
	 * @see com.accp.crm.service.IReportBizService#setSessionFactory(org.hibernate.SessionFactory)
	 */
    public void setSessionFactory(SessionFactory sessionFactory){
    	
    	ReportDAO=new CommonDAO<Report>(sessionFactory, Report.class);
    }

    /* (non-Javadoc)
	 * @see com.accp.crm.service.IReportBizService#add(com.accp.crm.entity.Report)
	 */
    public void add(Report report){
		
    	this.ReportDAO.save(report);
	}
 

 
 
    /* (non-Javadoc)
	 * @see com.accp.crm.service.IReportBizService#getSvrList(java.lang.String)
	 */
    public List getSvrList(String year){
		
    	String hql = "select s.svrType, COUNT(s) from CstService s "; 
		if (!year.isEmpty()){
			hql += "where year(s.svrCreateDate)="+year+" ";
		}
		hql += "group by s.svrType ";
		return this.ReportDAO.findByHQL(hql);
	}
}
